package com.zx.system.block.enums;

import lombok.Getter;

/**
 * <p>
 * description: 菜单类型枚举定义 <br>
 * create: 2024-12-21 22:59
 * </p>
 *
 * @author zhou  xun
 */
@Getter
public enum MenuTypeEnum {
    BUTTON("B", "按钮"),
    DIRECTORY("D", "目录"),
    MENU("M", "菜单");

    /**
     * code
     */
    private final String code;
    /**
     * 说明
     */
    private final String desc;

    MenuTypeEnum(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public static MenuTypeEnum getEnumByDesc(String desc) {
        for (MenuTypeEnum value : values()) {
            if (value.desc.equals(desc)) {
                return value;
            }
        }
        return null;
    }

    public static MenuTypeEnum getEnumByCode(String code) {
        for (MenuTypeEnum value : values()) {
            if (value.code.equals(code)) {
                return value;
            }
        }
        return null;
    }
}
